package com.zhuangjie.shop.pojo;

import com.zhuangjie.coupon.pojo.CouponCoreInfo;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

/**
 * 使用优惠券详细信息
 *
 * @author zhuangjie
 * @date 2024/03/29
 */
@Getter
public class UseCouponDetail {
    /**
     * 使用的店铺优惠券
     */
    private Map<CouponCoreInfo, BigDecimal> useShopCouponMap;
    /**
     * 使用的平台优惠券
     */
    private Map<CouponCoreInfo,BigDecimal> usePlatformCouponMap;
    /**
     * 店铺优惠总金额
     */
    private BigDecimal shopCouponPreferentialAmount;
    /**
     * 平台优惠总金额
     */
    private BigDecimal platformCouponPreferentialAmount;
    /**
     * 优惠券优惠后用户需要支付的金额
     */
    @Setter
    private BigDecimal couponPreferentialAfterOrderAmount;

    public void putShopCouponToMap(CouponCoreInfo couponCoreInfo, BigDecimal couponPreferentialAmount) {
        if (useShopCouponMap == null) {
            useShopCouponMap = new HashMap<>();
        }
        useShopCouponMap.put(couponCoreInfo, couponPreferentialAmount);
    }
    public void putPlatformCouponToMap(CouponCoreInfo couponCoreInfo, BigDecimal couponPreferentialAmount) {
        if (usePlatformCouponMap == null) {
            usePlatformCouponMap = new HashMap<>();
        }
        usePlatformCouponMap.put(couponCoreInfo, couponPreferentialAmount);
    }

    public void plusShopCouponPreferentialAmount(BigDecimal couponPreferentialAmount) {
        if (couponPreferentialAmount == null) {
            return;
        }
        if (shopCouponPreferentialAmount == null) {
            shopCouponPreferentialAmount = couponPreferentialAmount;
        }else {
            shopCouponPreferentialAmount = shopCouponPreferentialAmount.add(couponPreferentialAmount);
        }
    }
    public void plusPlatformCouponPreferentialAmount(BigDecimal couponPreferentialAmount) {
        if (couponPreferentialAmount == null) {
            return;
        }
        if (platformCouponPreferentialAmount == null) {
            platformCouponPreferentialAmount = couponPreferentialAmount;
        }else {
            platformCouponPreferentialAmount = platformCouponPreferentialAmount.add(couponPreferentialAmount);
        }
    }



}
